<?php
	unset($wheres);
	$wheres['phone'] = $phone;
	$wheres['today'] = strtotime(date('Y-m-d'));
	
	$uservalid = _SqlTool::getInfo('validcode', $wheres);
	
	if(!empty($uservalid))
	{
		if($uservalid['errornums'] >= 5)
		{
			$result['status'] = '0';
			$result['msg'] = '验证码错误次数过多';
			echoJSON($result);
			exit;
		}
		
		if($uservalid['code'] != $code)
		{
			unset($query,$data);
			$query['id'] = $uservalid['id'];
			$data['errornums'] = $uservalid['errornums']+1;
			
			_User::setUserValidCode($query, $data);
			$result['status'] = '0';
			$result['msg'] = '验证码输入错误';
			echoJSON($result);
			exit;
		}
		else
		{
			//删除验证码
			unset($query);
			$query['phone'] = $phone;
			_User::delUserValidCode($query);
		}
	}
	else
	{
		$result['status'] = '0';
		$result['msg'] = '请先获取验证码';
		echoJSON($result);
		exit;
	}
